require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
var vm = new Vue({
    el:"#security",
    data:{
        loginUid:userInfo.id,
        infoById:{}
    },
    mounted:function(){
        this.getUserInfoById();
    },
    methods:{
        //后退
        getBack:function(){
            history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //通过id获取账户信息
        getUserInfoById:function(){
            var that=this;
            var data={
                loginUid:that.loginUid
                // loginUid:1
            };
            this.ajax({url:"/happyi/getUserInfoById",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.infoById=b.json.data;
                }else{
                    vm.$refs.prompt.toast("获取信息失败！");
                }
            });
        },
        //跳转
        getNext:function(type){
            if(type==1){  //更换手机号
                if(this.infoById.mobile){
                    location.href="/happyi/replaceTel?tel="+this.infoById.mobile;
                }else{
                    location.href="/telLogin?type=11&loginUid="+this.loginUid;
                }

            }else if(type==1||type==2||type==3||type==4){  // 1 视频  2 游记 3 收藏 4 点赞
                location.href="/happyi/myVideo?type="+type
            }else if(type==5||type==6){
                location.href="/happyi/myFans?type="+type
            }else if(type==7){
                location.href="/happyi/myWallet";
            }else if(type==8){
                location.href="/happyi/myCoupon";
            }
        }
    }
});